<template>
	<view class="team-pae">
		<view class="header-box">
			<Header>
				<template #header>
					<Navbar title="我的团队" backgroundColor="transportant" :border="false" color="#333"></Navbar>
				</template>
				<view class="bottom">
				</view>
			</Header>
		</view>
		<view class="footer-box">
			<view class="footer df-column">
				<view class="item">
					<text class="title">我的奖励</text>
					<view class="wallet-box">
						<text>￥</text>
						<text class="val">540.00</text>
					</view>
				</view>
				<view class="item">
					<view class="top df-between">
						<text class="title">我的团队</text>
						<view class="right df-l">
							<text>查看数据</text>
							<image src="@/static/my/back.png" class="icon"></image>
						</view>
					</view>
					<view class="wallet-box team" @click="getInfos">
						<view class="item">
							<view class="top df-l">
								<text>下级人数（人）</text>
								<image src="@/static/right.png" mode="widthFix" class="icon"></image>
							</view>
							<text class="val">54</text>
						</view>
						<view class="item right">
							<view class="top df-l">
								<text>次级人数（人）</text>
								<image src="@/static/right.png" mode="widthFix" class="icon"></image>
							</view>
							<text class="val">54</text>
						</view>
					</view>
				</view>
				<text class="btn df-c" @click="share">立即邀请</text>
			</view>
			<image src="@/static/team_bg.png" mode="widthFix" class="bg"></image>
		</view>
		<uni-popup ref="popupRef" type="center" background-color="#fff" borderRadius="16rpx 16rpx 0rpx 0rpx"
			class="share-box">
			<view class="popup-content df-column">
				<view class="header df-between">
					<text class="title">分享</text>
					<text class="closeBtn black" @click="close(popupRef)"></text>
				</view>
				<view class="item-box">
					<view class="top df-between">
						<text class="title">下级做单补贴</text>
						<text class="val">2%</text>
					</view>
					<text class="info">您直接邀请的下级用户，平台将补贴您下级用户在本平台推广 结算金额的2%作为额外奖励</text>
				</view>
				<view class="item-box">
					<view class="top df-between">
						<text class="title" style="color: #333333">次级做单补贴</text>
						<text class="val">2%</text>
					</view>
					<text class="info">您直接邀请的下级用户，平台将补贴您下级用户在本平台推广 结算金额的0.5%作为额外奖励</text>
				</view>
				<view class="btn-box df-between">
					<view class="item df-column" @click="copy">
						<image src="@/static/team/copy.png" mode="widthFix" class="btn"></image>
						<text>复制链接</text>
					</view>
					<view class="item df-column" @click="showPoster">
						<image src="@/static/team/poster.png" mode="widthFix" class="btn"></image>
						<text>生成海报</text>
					</view>
				</view>
			</view>
		</uni-popup>
		<uni-popup ref="popupImgRef" type="center" background-color="transportant">
			<view class="popup-body df-column">
				<view class="header df-r">
					<text class="closeBtn white" @click="close(popupImgRef)"></text>
				</view>
				<image src="@/static/team/poster_bg.png" mode="widthFix" class="img"></image>
			</view>
		</uni-popup>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import Header from '@/components/heder/index.vue'
	import Navbar from '@/components/navbar/index.vue'

	const popupRef = ref()

	const getInfos = () => {
		uni.navigateTo({
			url: '/pages/tabbar/team/teamInofs'
		})
	}
	const share = () => {
		popupRef.value?.open()
	}
	const close = (ref) => {
		ref?.close()
	}
	const copy = () => {
		uni.setClipboardData({
			data: '254',
			success: (res) => {
				console.log(res, 'ress--');
			}
		})
	}
	const popupImgRef = ref()
	const showPoster = () => {
		popupImgRef.value?.open()
	}
</script>

<style lang="scss" scoped>
	.team-pae {
		display: flex;
		flex-direction: column;
		flex: 1;
		overflow: hidden;

		.header-box {
			position: sticky;
			top: 0;

			.header {
				height: 90rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 0 30rpx;
				box-sizing: border-box;

				&>.left {
					font-weight: 400;
					font-size: 30rpx;
					color: #427DFF;

					&>.icon {
						width: 50rpx;
						height: 50rpx;
						border-radius: 50%;
						background-color: #427DFF;
						margin-right: 12rpx;
					}
				}

				&>.right {
					&>.icon {
						width: 30rpx;
					}

					&>.icon:first-child {
						margin-right: 30rpx;
					}
				}
			}

			.bottom {
				height: 260rpx;
				background: url('@/static/team_card.png') no-repeat;
				background-position: center;
				background-size: 100% 100%;
			}
		}

		&>.footer-box {
			height: calc(100vh - 440rpx);
			overflow-y: scroll;

			&::-webkit-scrollbar {
				width: 0;
			}

			.footer {
				padding: 0 30rpx;
				box-sizing: border-box;
				font-size: 30rpx;
				color: #666666;

				&>.item {
					margin: 24rpx 0 30rpx 0;

					.title {
						display: block;
						margin-bottom: 20rpx;
					}

					&>.wallet-box {
						background: linear-gradient(-90deg, #6F9CFF, #427DFF);
						box-shadow: 0px 10rpx 16rpx 0px rgba(66, 125, 255, 0.4);
						border-radius: 16rpx;
						color: #fff;
						font-size: 24rpx;
						vertical-align: middle;
						padding: 51rpx 34rpx;
						box-sizing: border-box;

						&>.val {
							font-size: 48rpx;
						}
					}

					.right {
						align-items: center;
						gap: 10rpx;
						font-size: 24rpx;
						color: #999999;

						.icon {
							width: 12rpx;
							height: 20rpx;
						}
					}

					&>.team {
						font-size: 24rpx;
						color: #999999;
						background: #fff;
						box-shadow: 0px 4rpx 6rpx 0px rgba(175, 175, 175, 0.1);
						display: flex;
						align-items: flex-start;
						padding: 30rpx;
						box-sizing: border-box;

						&>.item {
							width: 50%;

							&>.top {
								gap: 10rpx;
								align-items: center;

								&>.icon {
									width: 20rpx;
								}
							}

							&>.val {
								font-size: 40rpx;
								color: #333;
								text-indent: 22rpx;
								margin-top: 28rpx;
							}
						}

						&>.right {
							padding-left: 30rpx;
							position: relative;

							&:before {
								content: '';
								width: 2rpx;
								height: 80rpx;
								position: absolute;
								top: 10rpx;
								left: 0;
								background-color: #DDDDDD;
							}
						}
					}

				}

				&>.btn {
					height: 90rpx;
					font-size: 36rpx;
					color: #fff;
					background: #427DFF;
					border-radius: 45px;
					margin-bottom: 40rpx;
				}
			}

			&>.bg {
				width: 100%;
				margin: 0 auto;
			}
		}

		&>.share-box {
			:deep(.uni-popup__wrapper) {
				top: 184rpx;
			}
		}

		.closeBtn {
			width: 26rpx;
			height: 27rpx;
			background-size: cover !important;
			background-position: center !important;
		}

		.popup-content {
			width: 100vw;
			padding: 30rpx;
			box-sizing: border-box;

			&>.header {
				&>.title {
					flex: 1;
					font-size: 36rpx;
					color: #333333;
					font-weight: 500;
					text-align: center;
				}

				&>.black {
					background: url('@/static/team/close.png') no-repeat;
				}
			}

			&>.item-box {
				margin-top: 30rpx;
				background: linear-gradient(0deg, #FFFFFF 0%, #EFF4FF 100%);
				border-radius: 16rpx;
				border: 2rpx solid #427DFF;
				padding: 20rpx;
				box-sizing: border-box;

				&>.top {
					color: #427DFF;
					font-size: 30rpx;

					&>.val {
						color: #F44242;
					}

					margin-bottom: 30rpx;
				}

				&>.info {
					color: #999999;
					font-size: 24rpx;
				}
			}

			.btn-box {
				margin: 40rpx auto;
				width: 50%;

				&>.item {
					color: #999;
					font-size: 24rpx;
					align-items: center;

					&>.btn {
						width: 90rpx;
					}
				}
			}
		}

		.popup-body {
			.white {
				background: url('@/static/team/close_white.png') no-repeat;
				margin-bottom: 32rpx;
			}

			&>.img {
				width: 560rpx;
			}
		}
	}
</style>